home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / commio0b.zip / DOORIO.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-13  |  34KB  |  996 lines

  1. {$X+}
  2. unit DOORIO;
  3. {
  4.           This unit is a companion to the COMMIO communications unit.
  5.                 Written by Jason Morriss a.k.a. Lief O'Pardy
  6.  
  7.                   Copyright (C) 1995,1996 by Jason Morriss
  8.  
  9.   This unit has a group of procedures and functions for getting input from
  10.   the user in various ways, and writting text in various ways, including
  11.   some animation.
  12.   Some of the following routines CAN NOT be used over the modem since there's
  13.   no way to "TELL" the other computer how to do it.  They are here because
  14.   this unit used to be my own IO unit for my "normal" programs, i just
  15.   converted it for these DOOR routines, and then added more routines
  16.   ... enjoy.
  17. }
  18. INTERFACE
  19.  
  20. uses crt, commio;
  21.  
  22. Type
  23.   TCharSet = Set of Char;
  24.   Tauto = (noauto,upper,lower,smart);
  25.   Twriter = (nofx,wipe1,fadein,fadeout);
  26. Var
  27.   Pause_Proc: procedure(s:string);
  28. {  More_Proc : function(s:string;chs:tcharset):TMoreResults;}
  29. Const Charset : tcharset = [#32..#232,#234..#255];
  30. Const NumSet  : tcharset = ['0'..'9','-'];
  31. Const
  32. {  pausestr  : string[100] = 'Θ|1ΘB <PAUSE> Θ|0';
  33.   pausestrl : byte = 9;{}
  34.   inserton  : boolean = false;
  35. {--[v- how the string is displayed with putstr/xy() ]--}
  36.   writer    : Twriter = nofx;
  37.   dlay      : array[Twriter] of word = (0,10,100,100);
  38. {--[v- if true Getstr() will echo "secretchar" (used for passwords) ]--}
  39.   secret    : boolean = false;
  40.   secretchar: char = '█';
  41. {--[v- The Getstr() string will be filtered according to Tauto ]--}
  42.   autocaps  : Tauto = noauto;
  43. {--[v- if true input will be highlighted according to the const BGCol,
  44.        when using most input routines                                  ]--}
  45.   highlight : boolean = true;
  46. {--[v- These are the allowable exit keys for getstr(): ]--}
  47.   normalexitkeys : tcharset = [#27,#13];    {esc, enter}
  48. {--[v- Extended keys are the ones who send #0 first, then the scancode ]--}
  49.   extendedexitkeys : tcharset = [];
  50.  
  51.   FGCol   : Byte = 15;  {white}       { Fg color for most input routines }
  52.   BGCol   : Byte = 1;   {blue}        { Bg color for most input routines }
  53.  
  54.   DVseg   : word = $B800;  {.$B800=color; $B000 for mono}
  55.   DVofs   : word = $0000;  {the ofs is needed incase i/you create routines
  56.                             that will write to a virtual page, virtual pages
  57.                             will not always start at 0000.}
  58.  
  59. const
  60.   nomemory     = 1;
  61.   filenotfound = 2;
  62.  
  63. procedure terminate(s:string);
  64. {^ Halts the program with the Error String "s". }
  65. function CommaInt(number:longint):string;
  66. {^ Inserts comma's into a number and returns a string of the number with the
  67.    commas. ie: s:=Commint(1000000); (* s='1,000,000' *) Makes Larger numbers
  68.    easier to read. }
  69. function padFstr(s:string; ch:char; len:byte):string;
  70. {^ Pad the front of the string with CH, up to LEN. }
  71. function padEstr(s:string; ch:char; len:byte):string;
  72. {^ Pad the end of the string with CH, up to LEN. }
  73. function istr(n:longint; pad:byte):string;
  74. {^ converts a number to a string.
  75.      pad = how many 0's will be padded in front of the string, to make
  76.            the number a certain length. ie: istr(45,3) = '045'}
  77. function sint(s:string):longint;
  78. {^ converts a string to a number.  if the string is invalid, 0 is returned. }
  79. function CSLen(s:string):byte;
  80. {^ returns the length of the string, not including any of the "Θ" control
  81.    codes. }
  82. function UpChar(Ch:Char):Char;
  83. {^ converts the Char to upper case.  this also supports some foreign chars. }
  84. function LowChar(Ch:Char):Char;
  85. {^ converts the char to lower case.  "     "    "        "   "        ". }
  86. function UpCaseStr(s:string):string;
  87. {^ conerts a string to upper case; uses Upchar. }
  88. function LowCaseStr(s:string):string;
  89. {^ converts a string to lower case; uses Lowchar. }
  90. function SmartCaseStr(s:string):string;
  91. {^ converts a string to a PROPERLY capitalized string.  only useful for
  92.    names.  ie: "jasON moRRisS" = "Jason Morriss". }
  93. procedure hidecursor;
  94. {^ LOCAL ONLY: turns the cursor off; you can't see it on the screen, but its
  95.    still there. }
  96. procedure showcursor;
  97. {^ LOCAL ONLY: turns the cursor on, if it was off. }
  98. {function whereX:byte;
  99. {^ LOCAL ONLY: returns the X position of the cursor.  This is just like TP's
  100.    WhereX, except it is NOT window relitive. }
  101. {function whereY:byte;
  102. {^ LOCAL ONLY: returns the Y position of the cursor.  This is just like TP's
  103.    WhereY, except it is NOT window relitive. }
  104. procedure SetCursorSize(Top,Bot:Byte);
  105. {^ LOCAL ONLY: Set the size of the cursor.  top=top scanline; bot=bottom
  106.    scanline of cursor.  Both in the range of 1..8.  (7,8)="normal" cursor,
  107.    (1,8)=block cursor... }
  108. procedure KillBlanks(var s:string);
  109. {^ Kills ALL blanks in the string. }
  110. procedure KillExtraBlanks(var s:string);
  111. {^ Kills any blanks in FRONT of, and at the END of the string. }
  112. function AreYouSureY : char;
  113. {^ Special procedure.  Displays a colored "[Y,n]" prompt and returns when the
  114.    user presses either: 'Y','N',<enter>.  If <enter> is pressed then 'Y' is
  115.    returned. }
  116. function AreYouSureN : char;
  117. {^ Special procedure.  Displays a colored "[y,N]" prompt and returns when the
  118.    user presses either: 'Y','N',<enter>.  If <enter> is pressed then 'N' is
  119.    returned. }
  120. procedure GetPW(var st:string; len:byte);
  121. {^ Special procedure.  Get a password from the user.  the character echoed
  122.    is in the "secretchar" variable above. }
  123. procedure GetInt(var num:longint; hotkey:boolean; l:longint; h:longint);
  124. {^ Special procedure.  Get a number from the user.  l=lowest # allowed,
  125.    h=highest # allowed.  If hotkey is true then the user will not always
  126.    have to push enter after entering the number.  example:  if you want to
  127.    get a number in the range of 1 to 500 and the user enters 325 then he/she
  128.    won't have to hit enter, it will return the 325, since if the user were to
  129.    enter ANY other number after the 5 (in 325) then the number would be
  130.    larger then the maximum you set of 500.  But if the user enters something
  131.    like 20 then he/she will have to push enter.  otherwise it will wait until
  132.    the user pushes enter, to return the value.  got it?  negitive numbers are
  133.    allowed also. }
  134. function HotKey(CharSet:TCharSet):char;
  135. {^ Special procedure.  Get A char from the user.  CharSet is the set of
  136.    allowable characters to be pressed, any other character not in this
  137.    set is ignored.  As soon as one of the allowed chars is read, it returns
  138.    that char.  This does not echo any characters. }
  139. function GetStr(var DestStr:String; MaxLen:Byte; CharSet:TCharSet):char;
  140. {^ Get a string from the user.  If DestStr is not empty then the user starts
  141.    with that string, and the cursor starts at the end of the string (this
  142.    will write the string to the screen).  MaxLen is the maximum allowed
  143.    length of the string (duh).  CharSet is the set of chars allowed to be
  144.    entered into the string.  Also, look at the front of this unit, there are
  145.    a bunch of other variables that effect the output of this routine.  This
  146.    function returns the char that terminated the function. }
  147. procedure PutStr(S:string);
  148. {^ Powerful writting routine.  Color codes can be put directly into the
  149.    string to change colors easily.  Also there are a few animation Codes
  150.    also, you can easily write your own animation procedures and include them
  151.    also; that ofcourse requires a recompilation.
  152.    The CODE is: "Θ" (alt+233).
  153.    To change colors, the CODE comes first then one of the following chars:
  154.     --------------------------------------------
  155.     0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F (UPPERCASE!)
  156.     a,b,c,d,e,f,g,h                 (LOWERCASE!)
  157.     [,]
  158.     --------------------------------------------
  159.     The first line has all the values for changing the Foreground color.
  160.       They must be UPPERCASE.  The values are the standard TP set, in
  161.       that:  0=black, 1=blue, 2=green, ..., F (15)=white.
  162.     The second line has all the values for changing the Background color.
  163.       They must be LOWERCASE.  The values here go like: a=black, b=blue,
  164.       c=green, d=cyan, e=red, f=magenta, g=brown, h=lgtgray, the same order
  165.